<script language="javascript" type="text/javascript">
<!--
function popup(url) {
	newwindow=window.open(url,'name','height=220,width=250,top=150,left=560');
	if (window.focus) {newwindow.focus()}
	return false;
}
// -->
</script>
<?PHP
function convEnt($text){
return strip_tags(str_replace(
array("'",';', '"'), 
array("",'', ''), $text));
}
if (!file_exists("../config.php")) { 
echo "Missing config.php"; die;
}
if (!is_writable("../config.php")) {
echo "config.php is not writable"; die;
}
function get_value_of($name)
{
     $lines = file("../config.php");
	 $val = array();
     foreach (array_values($lines) AS $line)
     {
	 if (strstr($line,"="))
	 {
          list($key, $val) = explode('=', trim($line) );
          if (trim($key) == $name)
          {     $val = convEnt($val);
                return $val;
          }
     }
     }
     return false;
} 

function write_value_of($var,$oldval,$newval)
{
$contents = file_get_contents('../config.php');
$regex = '~\\'.$var.'\s+=\s+\''.$oldval.'\';~is';
$contents = preg_replace($regex, "$var = '$newval';", $contents);
file_put_contents('../config.php', $contents);
}

function get_lang_of($name)
{
     $lines = file("../lang/english.php");
     foreach (array_values($lines) AS $line)
     {
	 if (strstr($line,"="))
	 {
          list($key, $val) = explode('=', trim($line) );  
          if (trim($key) == $name)
          {     $val = convEnt($val);
                return $val;
          }
		  }
     }
     return false;
} 

//echo get_value_of('$hot_topics_post');

/*
$file = "../config.php";
$file_contents = file_get_contents($file);

$fh = fopen($file, "w");
$file_contents = str_replace('$topics_per_page = \'10\'','$topics_per_page = \'5\'',$file_contents);
fwrite($fh, $file_contents);
fclose($fh);
*/
function convEnt2($text){
return strip_tags(str_replace(
array("'",'<', '>'), 
array('&#039;','&lt;', '&gt;'), $text));
}

//function to validate ip address format in php by Roshan Bhattarai(http://roshanbh.com.np)
function validateIpAddress($ip_addr)
{
  //first of all the format of the ip address is matched
  if(preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$ip_addr))
  {
    //now all the intger values are separated
    $parts=explode(".",$ip_addr);
    //now we need to check each part can range from 0-255
    foreach($parts as $ip_parts)
    {
      if(intval($ip_parts)>255 || intval($ip_parts)<0)
      return false; //if number is not within range of 0-255
    }
    return true;
  }
  else
    return false; //if format of ip address doesn't matches
}

?>